using System;

namespace Scenario.Modules.DM.DataModel
{
	public class XMLDocumentMigrate : bOSdotNET.XML.Data.XMLObject 
	{
		public const string MAIN_NODE	= "Migrate";

		public const string FROM_ATTRIBUTE		= "From";
		public const string TO_ATTRIBUTE		= "To";
		public const string REEXEC_ATTRIBUTE	= "ReExec";
		public const string TYPE_ATTRIBUTE		= "Type";
		public const string FILE_ATTRIBUTE		= "File";

		public const string YES_REXEC	= "YES";
		public const string NO_REXEC	= "NO";

		public const string EMBEDDED_TYPE	= "EMBEDDED";
		public const string XSLT_TYPE		= "XSLT";
		public const string DOTNET_TYPE		= "CLASS";
		public const string COPY_TYPE		= "COPY";

		private string sFrom;
		private string sTo;
		private string sReExec;
		private string sType;
		private string sFile;

		public XMLDocumentMigrate()
		{
			this.Init();
		}

		public XMLDocumentMigrate(System.Xml.XmlNode node)
		{
			this.Parse(node);
		}

		public string From
		{
			get { return sFrom;}
			set { sFrom = value;}
		}

		public string To
		{
			get { return sTo;}
			set { sTo = value;}
		}

		public string ReExec
		{
			get { return sReExec;}
			set { sReExec = value;}
		}

		public string Type
		{
			get { return sType;}
			set { sType = value;}
		}

		public string File
		{
			get { return sFile;}
			set { sFile = value;}
		}

		override public void Init()
		{
			sFrom = string.Empty;
			sTo = string.Empty;
			sReExec = string.Empty;
			sType = string.Empty;
			sFile = string.Empty;
		}

		override public void Parse(System.Xml.XmlNode node2Parse)
		{
			this.Init();

			System.Xml.XmlNode node;

			for ( int i=0; i<node2Parse.Attributes.Count;i++)
			{
				node = node2Parse.Attributes.Item(i);

				switch ( node.Name )
				{
					case XMLDocumentMigrate.FROM_ATTRIBUTE:
						sFrom = node.InnerText;
						break;
					case XMLDocumentMigrate.TO_ATTRIBUTE:
						sTo = node.InnerText;
						break;
					case XMLDocumentMigrate.REEXEC_ATTRIBUTE:
						sReExec = node.InnerText;
						break;
					case XMLDocumentMigrate.TYPE_ATTRIBUTE:
						sType = node.InnerText;
						break;
					case XMLDocumentMigrate.FILE_ATTRIBUTE:
						sFile = node.InnerText;
						break;
				}
			}
		}

		override public bOSdotNET.XML.XMLNode GetXMLNode()
		{
			bOSdotNET.XML.XMLNode xmlNode = new bOSdotNET.XML.XMLNode(XMLDocumentMigrate.MAIN_NODE);

			xmlNode.AddAttribute ( new bOSdotNET.XML.XMLAttribute (XMLDocumentMigrate.FROM_ATTRIBUTE, sFrom) );
			xmlNode.AddAttribute ( new bOSdotNET.XML.XMLAttribute (XMLDocumentMigrate.TO_ATTRIBUTE, sTo) );
			xmlNode.AddAttribute ( new bOSdotNET.XML.XMLAttribute (XMLDocumentMigrate.REEXEC_ATTRIBUTE, sReExec) );
			xmlNode.AddAttribute ( new bOSdotNET.XML.XMLAttribute (XMLDocumentMigrate.TYPE_ATTRIBUTE, sType) );
			xmlNode.AddAttribute ( new bOSdotNET.XML.XMLAttribute (XMLDocumentMigrate.FILE_ATTRIBUTE, sFile) );
		
			return xmlNode;
		}
	}
}
